package com.aote.expression.paramprocessor;

import java.util.Hashtable;
import java.util.List;
import java.util.Map;

import com.aote.expression.Param;
import com.aote.util.BSCalendarHelper;
import com.aote.util.SingleValueHelper;
import com.browsesoft.EntityManager;
import com.browsesoft.dbtools.DBTools;
import com.browsesoft.htmlcomponent.HTMLBasicComponent;
import com.browsesoft.tools.BSCalendar;
import com.browsesoft.user.User;

/**
 * 单值参数处理器
 */
public class SingleValueProcessor implements ParamProcessor {
	public String process(Param param, Map attribures, User loginUser,
			HTMLBasicComponent component) {
		String result = "";
		String name = getSingleName(param, attribures);
		result = SingleValueHelper.getStringValue(name);
		return result;
	}

	private String getSingleName(Param param, Map attribures) {
		Map map = param.getParams();
		// 取出单值
		String name = (String) map.get("name");
		if (name != null && !name.equals("")) {
			return name;
		}
		// 取出用户类型
		String field = (String) map.get("field");
		// 特殊字符拼接
		String str = (String) map.get("str");
		if (attribures.get(field) != null) {
			if (str != null) {
				return (String) attribures.get(field) + str;
			}
			return (String) attribures.get(field);
		} else {
			return "";
		}
	}

}
